import ConfirmModal from "@/components/ConfirmModal";
import { Button } from "antd";
import { Component, useRef } from "react";

const OpenConfirmModal = ({
  type,
  text,
  onConfirm,
}: {
  type: "success" | "error" | "warning" | "info";
  text: string;
  onConfirm: any;
}) => {
  const modalRef = useRef<Component | null>(null);

  return (
    <div>
      <ConfirmModal
        type={type}
        text={text}
        ref={modalRef}
        onConfirm={(close) => {
          onConfirm && onConfirm();
          close();
        }}
      />
      <Button onClick={() => modalRef.current?.open()} type="primary">
        打开
      </Button>
    </div>
  );
};
export default OpenConfirmModal;
